package com.information.manage.basic.common.config;

import com.information.manage.basic.common.result.Result;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常捕捉
 **/
@RestControllerAdvice
public class ExceptionController {

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(Exception.class)
    public Result runException(Exception e) {
        e.printStackTrace();
        Result<Object> objectResultVo = new Result<>();
        objectResultVo.setCode(500);
        objectResultVo.setMsg(e.getMessage());
        return objectResultVo;
    }
}

